package com.xzx.shop_front_api.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@Component
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "es_news_index")
public class ESNews {

    //映射的_id
    @Id
    private Long id;

    @Field(name = "title", type = FieldType.Text, analyzer = "ik_max_word")
    private String title;
    @Field(name = "content", type = FieldType.Text, analyzer = "ik_max_word")
    private String content;
    @JsonProperty("cate_id")
    @Field(name = "cate_id", type = FieldType.Integer)
    private int cateId;

    @Field(name = "create_time", type = FieldType.Integer)
    private int createTime;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getCateId() {
        return cateId;
    }

    public void setCateId(int cateId) {
        this.cateId = cateId;
    }

    public int getCreateTime() {
        return createTime;
    }

    public void setCreateTime(int createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "ESNews{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", cateId=" + cateId +
                ", createTime=" + createTime +
                '}';
    }
}
